﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TT.Module.sysLogin;
using System.Data;
using Exp.BillDLL.ety;

namespace Exp.BillDLL.dao
{
    public class daoExpDetail
    {
        etyBaeSystemParamter basSysParam;

        public daoExpDetail(etyBaeSystemParamter ibasSysParam)
        {
            basSysParam = ibasSysParam;
        }

        public DataTable GetDetailPage(etyTmYmsYD inEty)
        {
            string sql = "select YID,YD_NO,CLIENT_NAME,YW_TYPE_DESC,SF_DESC,CITY_DESC,QX_DESC,YF_AMT,CREATE_TIME,qty,wgt,ELE_CONFIRM,EXP_AMOUNT "
                + " from vw_tm_yms_yd ";
            if (inEty.FROM_DATE.Trim() == "")
            {
                sql += " where rownum<200 order by create_time desc ";
            }
            else
            {
                sql += " where create_time between to_date(:from_date,'yyyymmdd') AND to_date(:to_date,'yyyymmdd') ";
                if (inEty.CLIENT_ID.Trim() != "" && inEty.CLIENT_ID.Trim() != "-1")
                {
                    sql += " and client_id=:client_id ";
                }
                if (inEty.YW_TYPE.Trim() != "" && inEty.YW_TYPE!="-1")
                {
                    sql += " and yw_type=:yw_type ";
                }
            }
            if (inEty.Bill_Filter == "Billed")
                sql += " and exp_amount is not null ";
            return basSysParam.SqlHelp.ExecuteReader(sql, inEty);
        }

        public DataTable GetDetailPriceSeq(etyTmYmsYD inEty)
        {
            string sql = "select t.* from charge_dtl c "
                + " inner join vw_bill_price t on c.price_seq=t.PRICE_SEQ"
                + " where bill_key=:YD_NO ";

            return basSysParam.SqlHelp.ExecuteReader(sql, inEty);
        }
    }
}
